// pages/activity/showGift.js
const app = getApp()
Page({
    data: {
        btnImg: '//resource.160nurse.com/canvas/healthy/img/activity/takepartgift.png'
    },
    onLoad: function (options) {
        console.log(options.order_no)
        var that = this
        app.request(app.apiDomain + 'index.php?c=user&a=orderdetail', {
            order_no: options.order_no,
            user_id: options.user_id
        }, res => {
            console.log(res);
            // 如果pay_method = 5  && status= 2 表示礼物已领取
            if(res.data.data.pay_method == '5' && res.data.data.status == '2'){
                this.setData({
                    info: res.data.data,
                    btnImg: '//resource.160nurse.com/canvas/healthy/img/activity/extract_1.png'
                })
            }else{
                that.setData({
                    info: res.data.data,
                    order_no: options.order_no,
                    user_id: options.user_id
                })
            }
        })
    },
    takeApart() {
        // 如果pay_method = 5  && status= 2 表示礼物已领取
        if (this.data.info.pay_method == '5' && this.data.info.status == '2') {
            wx.navigateTo({
                url: '/pages/index/index'
            })
        } else {
            wx.navigateTo({
                url: 'showGift?order_no=' + this.data.order_no + '&user_id=' + this.data.user_id
            })
        }
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})
